<template>
  <div>
    <div class="block">
      <span class="demonstration">开始时间</span>
      <el-date-picker
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          v-model="startTime"
          type="date"
          placeholder="选择日期">
      </el-date-picker>
    </div>
    <div class="block">
      <span class="demonstration">结束时间</span>
      <el-date-picker
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          v-model="lastTime"
          type="date"
          placeholder="选择日期">
      </el-date-picker>
    </div>
    <el-table
        :data="tableData"
        border
        style="width: 100%">
      <el-table-column
          prop="logisticsoption"
          label="物流类型"
          :formatter="logType"
          width="180">
      </el-table-column>
      <el-table-column
          prop="logsatisfy"
          label="满足率"
          width="180">
      </el-table-column>
      <el-table-column
          prop="logsatisfyshift"
          :formatter="shiftType"
          label="数据变化"
          width="180">
      </el-table-column>
      <el-table-column
          prop="price"
          label="价格">
      </el-table-column>
      <el-table-column
          prop="priceshift"
          :formatter="shiftType"
          label="价格变化">
      </el-table-column>
      <el-table-column
          prop="logchange"
          label="变动原因">
      </el-table-column>
      <el-table-column
          prop="creatDate"
          label="创建时间">
      </el-table-column>
    </el-table>
    <div>
      <el-button type="primary" @click="selectHistory">查询</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "LogHistory",
  data() {
    return{
      startTime:"",
      lastTime:"",
      tableData: [],
    }
  },
  methods:{
    selectHistory(){
      const _this = this
      console.log(_this.startTime)
      console.log(_this.lastTime)
      axios.get('http://localhost:8081/log/date?startDate='+_this.startTime+'&lastDate='+_this.lastTime).then(function (resp){
        _this.tableData = resp.data
      })
    },
    logType:function (row, column, cellValue){
      if (cellValue == "1"){
        return '公路情况'
      }
      if (cellValue == "2"){
        return '铁路情况'
      }
      if (cellValue == "3"){
        return '水运情况'
      }
      if (cellValue == "4"){
        return '航运情况'
      }
      if (cellValue == "5"){
        return "其他情况"
      }
    },
    shiftType:function (row,column,cellValue){
      if (cellValue == "1"){
        return '上升'
      }
      if (cellValue == "2"){
        return '下降'
      }
      if (cellValue == "3"){
        return '不变'
      }
    },
  },
  created() {
    const _this = this
  }
}
</script>

<style scoped>

</style>